﻿use SSODemo;

--region Drop Existing Procedures

IF OBJECT_ID(N'[usp_InsertApp]') IS NOT NULL
	DROP PROCEDURE [usp_InsertApp]

IF OBJECT_ID(N'[usp_UpdateApp]') IS NOT NULL
	DROP PROCEDURE [usp_UpdateApp]

IF OBJECT_ID(N'[usp_DeleteApp]') IS NOT NULL
	DROP PROCEDURE [usp_DeleteApp]

IF OBJECT_ID(N'[usp_SelectApp]') IS NOT NULL
	DROP PROCEDURE [usp_SelectApp]

IF OBJECT_ID(N'[usp_SelectAppsAll]') IS NOT NULL
	DROP PROCEDURE [usp_SelectAppsAll]

--endregion

GO

--region [usp_InsertApp]

------------------------------------------------------------------------------------------------------------------------
-- Generated By:   Zyg
-- Procedure Name: [usp_InsertApp]
-- Date Generated: 2009-04-27
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [usp_InsertApp]
	@Name varchar(255),
	@Url varchar(200),
	@IP varchar(40),
	@Port int,
	@DateCreated datetime,
	@PictureAddress varchar(255),
	@LoginFile varchar(255),
	@ID uniqueidentifier
AS

SET NOCOUNT ON

INSERT INTO [App] (
	[ID],
	[Name],
	[Url],
	[IP],
	[Port],
	[DateCreated],
	[PictureAddress],
	[LoginFile]
) VALUES (
	@ID,
	@Name,
	@Url,
	@IP,
	@Port,
	@DateCreated,
	@PictureAddress,
	@LoginFile
)

--endregion

GO

--region [usp_UpdateApp]

------------------------------------------------------------------------------------------------------------------------
-- Generated By:   Zyg
-- Procedure Name: [usp_UpdateApp]
-- Date Generated: 2009-04-27
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [usp_UpdateApp]
	@ID uniqueidentifier,
	@Name varchar(255),
	@Url varchar(200),
	@IP varchar(40),
	@Port int,
	@DateCreated datetime,
	@PictureAddress varchar(255),
	@LoginFile varchar(255)
AS

SET NOCOUNT ON

UPDATE [App] SET
	[Name] = @Name,
	[Url] = @Url,
	[IP] = @IP,
	[Port] = @Port,
	[DateCreated] = @DateCreated,
	[PictureAddress] = @PictureAddress,
	[LoginFile] = @LoginFile
WHERE
	[ID] = @ID

--endregion

GO

--region [usp_DeleteApp]

------------------------------------------------------------------------------------------------------------------------
-- Generated By:   Zyg
-- Procedure Name: [usp_DeleteApp]
-- Date Generated: 2009-04-27
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [usp_DeleteApp]
	@ID uniqueidentifier
AS

SET NOCOUNT ON

DELETE FROM [App]
WHERE
	[ID] = @ID

--endregion

GO

--region [usp_SelectApp]

------------------------------------------------------------------------------------------------------------------------
-- Generated By:   Zyg

-- Procedure Name: [usp_SelectApp]
-- Date Generated: 2009-04-27
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [usp_SelectApp]
	@ID uniqueidentifier
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[Name],
	[Url],
	[IP],
	[Port],
	[DateCreated],
	[PictureAddress],
	[LoginFile]
FROM
	[App]
WHERE
	[ID] = @ID

--endregion

GO

--region [usp_SelectAppsAll]

------------------------------------------------------------------------------------------------------------------------
-- Generated By:   Zyg
-- Procedure Name: [usp_SelectAppsAll]
-- Date Generated: 2009-04-27
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [usp_SelectAppsAll]
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[Name],
	[Url],
	[IP],
	[Port],
	[DateCreated],
	[PictureAddress],
	[LoginFile]
FROM
	[App]

--endregion

GO

